package com.touzi.utils;

import com.touzi.beans.dbs.users.NewUser;
import com.touzi.beans.dbs.users.UserToUpdate;

import javax.servlet.http.HttpServletRequest;

public class UsersUtils {
//    public static NewUser getNewUserFromRequest(HttpServletRequest request) {
//        //dianhua,mima,zhifubao,zhenming,tuijianren,zhuceshijian
//        String dianhua = request.getParameter("dianhua");
//        String mima = request.getParameter("mima");
//        String zhifubao = request.getParameter("zhifubao");
//        String zhenming = request.getParameter("zhenming");
//        String tuijianren = request.getParameter("tuijianren");
//        return new NewUser(dianhua, mima, zhifubao, zhenming, Integer.valueOf(tuijianren));
//    }

    public static NewUser getNewUserFromRequest(HttpServletRequest request) {
        //dianhua,mima,zhifubao,zhenming,tuijianren,zhuceshijian
        String dianhua = request.getParameter("phonenum");
        String mima = request.getParameter("passwd");
        String zhifubao = request.getParameter("alipay");
        String zhenming = request.getParameter("realname");
        String tuijianren = request.getParameter("recoid");
        return new NewUser(dianhua, mima, zhifubao, zhenming, Integer.valueOf(tuijianren));
    }

    public static UserToUpdate getUserToUp(HttpServletRequest request) {
        System.out.println(request.getParameter("id"));
        Integer id = Integer.valueOf(request.getParameter("id"));
        System.out.println(id);
        String dianhua = request.getParameter("dianhua");
        String mima = request.getParameter("mima");
        String zhifubao = request.getParameter("zhifubao");
        String zhenming = request.getParameter("zhenming");
        float keyong = Float.parseFloat(request.getParameter("keyong"));
        String frozen = request.getParameter("frozen");
        return new UserToUpdate(id, dianhua, mima, zhifubao, zhenming, keyong, frozen);
    }
}
